home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group97a.txt
/
000093_icon-group-sender _Sun Mar 23 15:59:28 1997.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
3KB
Received: by cheltenham.cs.arizona.edu; Sun, 23 Mar 1997 18:39:54 MST
To: icon-group@cs.arizona.edu
Date: Sun, 23 Mar 1997 15:59:28 +1000
From: Stuart Robinson <Stuart.Robinson@anu.edu.au>
Message-Id: <3334C6C0.3538@anu.edu.au>
Sender: icon-group-request@cs.arizona.edu
Subject: Problem with Another Program
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
Content-Length: 2429
Hello. Marc Espie provided a solution to my last problem, for which I
am very thankful, but I have another problem which I was hoping
someone on comp.lang.icon could help me with.
A few weeks ago I posted a query to the newsgroup about a text
analysis program that I was trying to write. Here is the original
posting.
>I have a number of texts each line of which has been coded for three types
>of information. Each line of the text will be assigned a number and a
>code for two categories. The numbers are just whole numbers (raning from 1
>to 20 or so) and each category has four members (say, ABCD and WXYZ).
>Here is an example text:
>
>1 A X
>1 A Y
>1 B Y
>2 B Y
>
>Note that some successive lines share an index number (as in lines 1 and
>2 and 2 and 3). When that is the case, I would like the program to
>output the members of each category for the matched lines, as below:
>
>1-2 AA XY
>2-3 AB YY
I received responses from Jan Theodore Galkowski/Helen Andrea
Galkowski, Bob Alexander, and Todd A. Proebsting--each of whom I
would like to thank. Todd Proebsting contributed the following
program:
procedure main()
count := 0
last_index := ""
last_cat1 := ""
last_cat2 := ""
while s := read() do {
count +:= 1
s ? {
tab(upto(&digits++&letters)) # skip
initial non-letters/digits
index := tab(many(&digits++&letters)) # get
letters/digits
tab(upto(&digits++&letters))
cat1 := tab(many(&digits++&letters))
tab(upto(&digits++&letters))
cat2 := tab(many(&digits++&letters))
}
if index == last_index then {
write(count-1, "-", count, " ", last_cat1,
cat1, " ", last_cat2, cat2)
}
last_index := index;
last_cat1 := cat1;
last_cat2 := cat2;
}
end
This program is great, but it keeps track of only one index number per
line. However, the texts I will use the program to analyze contain
more than one index number per line. (Unfortunately, I failed to make
this clear in my original posting.) To highlight the problem, I will
provide an extract from a text (with inessential info ommitted):
{V.A 1{X
{V.B 7{X 8{Y
{V.B 7{X 8{Y